<template>
	<view class="beijingse">
		<view class="zzdbbox">
			<view class="strongtext xiaobai fonweight">可提现</view>
			<view class="sishi xiaobai margin_top2 fonweight">￥
				<text class="xiaobai fonweight" style="font-size: 70rpx;" v-if="type==2">{{userInfo.money}}</text>
				<text class="xiaobai fonweight" style="font-size: 70rpx;" v-if="type==3">{{userInfo.jb_num}}</text>
			</view>
		</view>
		<view class="mainpadding" style="position: relative; top: -110rpx;">
			<view class="ffffff radius mainpadding">
				<view class="ershiba xiaohei" v-if="type==2">提现金额（元）</view>
				<view class="ershiba xiaohei" v-if="type==3">提现金币（个）</view>
				<view class="flexbetween margin_top2">
					<view class="sishi xiaohei margin_top2 flexleft fonweight">￥
						<input type="number" class="xiaohei fonweight" style="font-size: 64rpx;height: 80rpx;" v-model="score" name="" id="">
					</view>
					<view class="ershiba xiaocheng" style="min-width: 120rpx ;" v-if="type==2" @click="score = userInfo.money">全部提现</view>
					<view class="ershiba xiaocheng" style="min-width: 120rpx ;" v-if="type==3" @click="score = userInfo.jb_num">全部提现</view>
				</view>
			</view>
			<view class="mainpadding radius ffffff margin_top">
				<view class="ershiba zhonghei">提现至</view>
				<view class="flexbetween margin_top">
					<view class="flexleft">
						<view class="margin_right1">
							<u-icon name="zhifubao-circle-fill" color="#5c9cf6" size="22"></u-icon>
						</view>
						<view class="ershiba xiaohei">提现至</view>
					</view>
					<u-icon name="checkmark-circle-fill" color="#FF9341" size="18"></u-icon>
				</view>
				<view class="xiaohong margin_top strongtext">{{content}}</view>
			</view>
			<view class="bigbtn " style="margin-top: 180rpx;" @click="submit">提现</view>
			<!-- <view class="xiaocheng textcenter margin_top sanshier" @click="jumpdetail('/pages_mypage/tixianjl?type=',type)">提现记录</view> -->
		</view>
	</view>
</template>
<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				userInfo: {},
				score: "", 
				type:1,//1佣金，2金币
				text:"",
				content:"",
			}
		},
		onLoad(options) {
			this.type = options.type
			let text = ""
			if(options.type==2){
				text = "佣金"
			}else if(options.type==3){
				text = "金币"
			}
			this.text = text
			uni.setNavigationBarTitle({
				title:text+"提现"
			})
			this.userinfomsg()
			this.system()
		},
		methods: {
			system() {
				httpRequest.request('/api/index/getConfigInfoItem', 'POST', {
					pidtype:this.text=='金币'? 'withdrawalset':'yjwithdrawalset',
					type:this.text=='金币'? 'withdrawal_des':'yjwithdrawal_des'
				}).then(res => {
					this.content = res.data
				})
			},
			
			userinfomsg() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			submit(){
				if(this.score==""){
					httpRequest.toast("请输入提现金额")
					return false
				}
				if(Number(this.score)>Number(this.userInfo.money) && this.type==2){
					httpRequest.toast("提现金额不可大于可提现金额")
					return false
				}
				if(this.score=="" && this.type==2){
					httpRequest.toast("请输入提现金额")
					return false
				}
				if(Number(this.score)>Number(this.userInfo.jb_num) && this.type==3){
					httpRequest.toast("提现金额不可大于可提现金额")
					return false
				}
				let data = {
					price:this.score,
					type:2,
					openid:"",
					withdrawal_type:this.type==2?2:1
				}
				let url = "/api/user/addWithdrawal"
				uni.showLoading({
					mask:true,
					title:"请稍后"
				})
				httpRequest.request(url, 'GET', data).then(res => {
					uni.hideLoading()
					httpRequest.toast(res.msg)
					if(res.code==1){
						setTimeout(()=>{
							uni.navigateBack(1)
						},1000)
					}else if(res.code==-1){
						setTimeout(()=>{
							uni.navigateTo({
								url:"/pages_mypage/xiugaizhifubao"
							})
						},1000)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.zzdbbox {
		background-size: 100% 100%;
		padding: 16rpx 30rpx 100rpx;
		background-image: url('@/static/image/system/tixianbg.png');
	}
</style>